<template>
    <el-tabs type="border-card" class="edittabform">
        <el-tab-pane label="数据">
            <el-row type="flex" class="editformitem" align="middle">
                <el-col :span="8" class="editlabel">
                    <span>数据表格</span>
                </el-col>
                <el-col :span="16" class="editcontent">
                    <el-select v-model="obj.tableData.tableId" filterable clearable placeholder="请选择数据" size="mini"
                        @change="tableSelectChange">
                        <el-option v-for="item in dataTableList" :key="item.id" :label="item.name" :value="item.id">
                        </el-option>
                    </el-select>
                </el-col>
            </el-row>
            <el-row type="flex" class="editformitem" align="middle">
                <el-col :span="8" class="editlabel">
                    <span>数值</span>
                </el-col>
                <el-col :span="16" class="editcontent">
                    <el-select v-model="obj.tableData.itemId" filterable clearable placeholder="请选择数据" size="mini">
                        <el-option v-for="item in columnData" :key="item.id" :label="item.name" :value="item.id">
                        </el-option>
                    </el-select>
                </el-col>
            </el-row>
            <!-- <el-row type="flex" class="editformitem">
          <el-col :span="8" class="editlabel">
            <span>数据查询范围</span>
          </el-col>
          <el-col :span="16" class="editcontent">
            <el-select v-model="obj.tableData.filterTimeType" placeholder="选择列时间范围" size="mini" style="width:190px;">
              <el-option label="15天" :value="15" />
              <el-option label="1天" :value="1" />
              <el-option label="7天" :value="7" />
              <el-option label="30天" :value="30" />
              <el-option label="90天" :value="90" />
              <el-option label="1年" :value="365" />
              <el-option label="全部" :value="99" />
            </el-select>
            <el-tooltip class="item" effect="dark" content="设置数据查询的时间范围，默认查询最近15天" placement="top-start">
              <i class="el-icon-warning formlabletips"></i>
            </el-tooltip>
          </el-col>
        </el-row> -->
            <!-- <el-row type="flex" class="editformitem">
            <el-col :span="8" class="editlabel">
                <span>最大值</span>
            </el-col>
            <el-col :span="16" class="editcontent">
                <input v-model.number="obj.tableData.maxNumber" class="miniinput" type="number" />
            </el-col>
        </el-row> -->
            <el-row type="flex" class="editformitem" align="middle">
                <el-col :span="8" class="editlabel">
                    <span>小数点位</span>
                </el-col>
                <el-col :span="16" class="editcontent">
                    <input v-model.number="obj.tableData.decimal" class="miniinput" type="number" />
                </el-col>
            </el-row>
            <el-row type="flex" class="editformitem">
                <el-col :span="8" class="editlabel">
                    <span>数字字体</span>
                </el-col>
                <el-col :span="16" class="editcontent">
                    <input v-model.number="obj.tableData.fontSize" class="miniinput" type="number" />
                    <el-color-picker v-model="obj.tableData.fontColor" size="small" show-alpha :predefine="predefineColors"
                        popper-class="mycolorview" @active-change="setColorChange(obj.tableData, 'fontColor', $event)" />
                    <div class="fontstylev">
                        <div :class="['fontitem', { 'active': obj.tableData.fontWeight == 'bold' }]"
                            @click="setFontStyle('fontWeight', obj.tableData, 'fontWeight')"><i
                                class="iconfont icon-zitijiacu"></i>
                        </div>
                        <div :class="['fontitem', { 'active': obj.tableData.fontStyle == 'italic' }]"
                            @click="setFontStyle('fontStyle', obj.tableData, 'fontStyle')"><i
                                class="iconfont icon-zitixieti"></i>
                        </div>
                    </div>
                </el-col>
            </el-row>
            <el-row type="flex" class="editformitem" align="middle" v-for="(item, index) in obj.tableData.statusList"
                :key="'status' + index">
                <el-col :span="8" class="editlabel">
                    <span>状态{{ index + 1 }}</span>
                </el-col>
                <el-col :span="16" class="editcontent sldyinput">
                    <input type="number" disabled v-if="index > 0" v-model="obj.tableData.statusList[index - 1].value1"
                        placeholder="无" style="width: 70px; line-height: 20px;margin-right:10px;" />
                    <input type="number" v-else v-model="item.value"
                        style="width: 70px; line-height: 20px;margin-right:10px;" placeholder="无" />
                    <input type="number" v-model="item.value1" placeholder="无"
                        style="width: 70px; line-height: 20px;margin-right:10px;" />
                    <el-color-picker popper-class="mycolorview" v-model="item.color" size="small" show-alpha
                        :predefine="predefineColors"
                        @active-change="setColorChange(obj.tableData.statusList[index], 'color', $event)" />
                    <i class="el-icon-error" v-if="index > 0" @click="deleteDataYinfo(obj.tableData.statusList, index)"></i>
                </el-col>
            </el-row>

            <div class="addybtn" @click="addStatusinfo(obj.tableData.statusList)" style="margin-right:0px;">
                + 添加状态
            </div>
        </el-tab-pane>
        <el-tab-pane label="样式">
            <el-row type="flex" class="editformitem">
                <el-col :span="8" class="editlabel">
                    <span>样式选择</span>
                </el-col>
                <el-col :span="16" class="editcontent">
                    <el-radio-group v-model="obj.tableData.styleTemplate" class="styletempradio">
                        <el-radio :label="0">普通</el-radio>
                        <el-radio :label="1">带刻度</el-radio>
                        <el-radio :label="2">渐变</el-radio>
                        <el-radio :label="3">移动率</el-radio>
                    </el-radio-group>
                </el-col>
            </el-row>
            <el-collapse v-model="collapseActives" class="edittypeform">
                <el-collapse-item title="标题" name="4">
                    <title-form :predefineColors="predefineColors" :obj="obj" :setColorChange="setColorChange"
                        :setFontStyle="setFontStyle"></title-form>
                </el-collapse-item>
            </el-collapse>
        </el-tab-pane>
        <el-tab-pane label="布局">
            <box-form :predefineColors="predefineColors" :obj="obj" :setColorChange="setColorChange"></box-form>
        </el-tab-pane>
    </el-tabs>
</template>

<script>

export default {
    name: "GaugeForm",
    components: {
        TitleForm: () => import('../mixin/TitleForm.vue'),
        BoxForm: () => import('../mixin/BoxForm.vue'),
    },
    props: {
        predefineColors: Array,
        obj: Object,
        dataTableList: Array,
        columnData: Array,
        tableSelectChange: Function,
        deleteDataYinfo: Function,
        setColorChange: Function,
        setFontStyle: Function,
    },
    model: {
        prop: "obj",
        event: "change",
    },
    methods: {
        addStatusinfo(item) {
            var parent = this.obj.tableData.statusList[this.obj.tableData.statusList.length - 1];
            item.push({ value: parent.value1, value1: "", color: this.predefineColors[item.length] });
        },
    }
}
</script>
